package ACWing.SearchAndGraphTheory.二分图;
//860. 染色法判定二分图

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2023/1/1 19:29
 */
public class DichotomousGraphDeterminedStainingMethod {
    static int n,m,idx;
    static int[]h=new int[100010];
    static int[]e=new int[100010];
    static int[]ne=new int[100010];
    static int[]color=new int[100010];
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        Arrays.fill(h,-1);
        for (int i = 0; i < m; i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            add(a,b);
            add(b,a);
        }
        for (int i = 1; i <= n; i++) {
            if(color[i]==0){//防止有不想连的连通块及俩个图没有相较的情况
                if(!dfs(i,1)){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");

    }
    public static void add(int a,int b){
        e[idx]=b;
        ne[idx]=h[a];
        h[a]=idx++;
    }
    public static boolean dfs(int u,int c){//根据dfs去遍历所有的相连边使其染色
        color[u]=c;//染色
        for (int i = h[u]; i !=-1; i=ne[i]) {
            int j=e[i];
            if(color[j]==0){
                if (!dfs(j,3-c)) {//精髓啊处理2 1反复使用
                    return false;
                }
            }else if(color[j]==c){//我的子节点与我出现相同的颜色便矛盾了
                return false;
            }
        }
        return true;
    }

}
